
import { message } from 'antd';
import { connect } from 'react-redux';
import CommonList from '../../../components/CommonLists/list';
import services from '../../../services/api';
import Modal from '../../../components/Modal/index';

@connect()
class DeptList extends CommonList {
  constructor(props) {
    super(props);
    this.api = 'dept';
    this.needOperateColumn = false
    this.tableParams = {
      scroll: {
        x: 1400
      }
    }
  }

  componentDidMount() {}

  delete(record) {
    Modal.open({
      title: '',
      isConfirm: true,
      width: '300px',
      content: '确定要删除?',
      isOkBtn: true,
      isCancelBtn: true,
      ok: () => {
        services[this.api].delete({ dept_id: record.dept_id }).then(data => {
          if (data.code === 0) {
            message.success(data.msg);
            this.props.queryList();
            this.props.dispatch({ type: 'global/queryDept', data: {} });
            Modal.close();
          } else {
            message.error(data.msg);
          }
        });
      },
      cancel: () => {
        Modal.close();
      }
    });
  }
}

export default DeptList;
